/*
 * 
 * Copyright 2010 David H Pollack
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License. 
 * 
 * 
 */

package com.dhpollack.rotogss.data;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.Text;

/**
 * @author davidpl
 *
 */
@PersistenceCapable
public class RotoGSSLeagueXml implements Serializable {

	@PrimaryKey
    @Persistent
    private Key leagueKey;
	
	@Persistent
	private Text leagueXml;
	
	@Persistent
	private Date updateTimestamp;
	
	@Persistent
	private Set<Key> googleUserKeys;

	public Key getLeagueKey() {
		return leagueKey;
	}

	public void setLeagueKey(final Key leagueKey) {
		this.leagueKey = leagueKey;
	}

	public String getLeagueXml() {
		return leagueXml.getValue();
	}

	public void setLeagueXml(final String leagueXml) {
		this.leagueXml = new Text(leagueXml);
	}

	public Date getUpdateTimestamp() {
		return updateTimestamp;
	}

	public void setUpdateTimestamp(final Date updateTimestamp) {
		this.updateTimestamp = updateTimestamp;
	}

	public void setUpdateTimestamp(final String updateTimestamp) {
		Date d = new Date();
		d.setTime(Long.parseLong(updateTimestamp) * 1000);
		this.updateTimestamp = d;
	}

	public Set<Key> getGoogleUserKeys() {
		return googleUserKeys;
	}

	public void setGoogleUserKeys(final Set<Key> googleUserKey) {
		this.googleUserKeys = googleUserKey;
	}
	
	public void addGoogleUserKey(final Key googleUserKey) {
		this.googleUserKeys.add(googleUserKey);
	}
	
	public void removeGoogleUserKey(final Key googleUserKey) {
		this.googleUserKeys.remove(googleUserKey);
	}
	

}
